<?php

namespace App\Services\DataCache;

use App\Caches\AdPlanCache;
use App\Services\ServiceBase;

class AdPlanDockingDataCache extends ServiceBase
{
    protected $planList;

    public function __construct()
    {
        parent::__construct();
        $msg = file_get_contents(storage_path("datacache/plan_docking.dat"));
        $this->planList = json_decode($msg, true);
    }

    public function get($plan_id)
    {
        if (!isset($this->planList[$plan_id])) {
            $plan = AdPlanCache::getInstance()->remember($plan_id);
            return $plan['media_docking_id'] ?? 0;
        } else {
            return $this->planList[$plan_id];
        }
    }
}
